unit u_senar;

interface

uses
u_player,
u_asus,
sysutils,
u_font,
system.Drawing,
system.windows.Forms,
Microsoft.DirectX,
Microsoft.DirectX.Direct3D,
Microsoft.DirectX.Direct3DX;

type
  c_senar = class
    private
      allie : texture;
      _sprite: sprite;
      nbr_fin:integer;
      type_enne:string;
      m,k : u_text;
    public
    nbr_ec : integer;
    mission : string;
    constructor create(dev : device);
    procedure affi_alli_selec(width, height: integer; selec: boolean; _type: string);
    procedure attente (myplayer : c_player);
    procedure quete_inhit;
    procedure affiche_quete(w,h : integer;dev : device;myplay : c_player);
  end;

implementation
uses
  u_engine;

constructor c_senar.create;
  begin
    inherited create;
    _sprite := sprite.Create(dev);

    allie := Textureloader.FromFile(dev, 'asus menu\in game\boulla_c.png');
    nbr_ec:=0;
    nbr_fin:=0;
    mission:='';
    m:= u_text.create(dev,14,color.Yellow,inttostr(nbr_ec)+'/' + inttostr(nbr_fin) + mission,'Comic Sans MS',FontStyle.Regular);
    m.set_coord(myform._width-100,50);
    m.set_visible(false);
    k:= u_text.create(myform._3D_device,14,color.black,'boullaynator','Comic Sans MS',FontStyle.Regular);
    k.set_coord(150,myform._height - 150);
    m.set_visible(false);
  end;

procedure c_senar.affi_alli_selec(width, height: integer; selec: boolean; _type: string);
var
  j: integer;
  z: single;
  m : u_text;
begin
  if (selec)and (_type = 'Gentil petit asus') then
  begin
  _sprite.&begin(SpriteFlags.AlphaBlend);
    _sprite.Draw(allie, Vector3.Create(0, 0 ,0), Vector3.Create(20, height - 150, 0), color.White.ToArgb);
  _sprite.&End;
  k.set_visible(true);
  k.text_render;

  end
  else
    k.set_visible(false);
end;

procedure c_senar.attente (myplayer : c_player);
var
  s : string;
begin

      s := reprise (myplayer.mychat.wait,myplayer.mychat.textrec);
      if s<>'' then
        myplayer.mychat.add_text(s);


end;

procedure c_senar.quete_inhit;
var
  i,j:integer;
  s:string;
begin
i:=1;

      while (i<=length(but))and not(but[i]in['1'..'9']) do
        i:=i+1;
      j:=i;
      while (j<=length(but))and (but[j]in['1'..'9']) do
        begin
          nbr_fin:= strtoint(but[j]);
          j:=j+1;
        end;
      j:=j+1;
      for i:=j to length(but)do
        s:=s+but[i];
      inhit:=false;
      mission:=s;
      nbr_ec:=0;
end;

procedure c_senar.affiche_quete(w,h : integer;dev : device;myplay : c_player);
var
b:boolean;
begin
if quetelance then
begin
  m.set_visible(true);
  m.change_text(inttostr(nbr_ec)+'/' + inttostr(nbr_fin) + mission);
  m.text_render;
  if nbr_ec=nbr_fin then
    begin
      obj:=true;
      quetelance:=false;
      konner:=true;
      but:='';
      mission:='';
      mars:=mars*10+1;
      counter:=1;
//      myplay.mychat.add_text( reprise (b,'1'));
    end;
end;

end;

end.
